package com.zuma.oci.docker.type;

import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson2.JSON;
import lombok.Data;

import java.nio.charset.StandardCharsets;

@Data
public class RegistryAuth {

    private String username;

    private String password;

    private String email;

    private String serverAddress;

    public static RegistryAuth create(String username, String password, String email, String serverAddress) {
        RegistryAuth registryAuth = new RegistryAuth();
        registryAuth.username = username;
        registryAuth.password = password;
        registryAuth.email = email;
        registryAuth.serverAddress = serverAddress;
        return registryAuth;
    }

    @Override
    public String toString() {
        return Base64.encode(JSON.toJSONString(this));
    }
}
